package com.zhuangwei.sell.converter;

import com.zhuangwei.sell.dataobject.OrderMaster;
import com.zhuangwei.sell.dto.OrderDto;
import org.springframework.aop.target.LazyInitTargetSource;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author LeviCoder
 * @create 2019-03-02 22:55
 */
public class OrderMaster2OrderDtoConverter {

    public static OrderDto convert(OrderMaster orderMaster){
        OrderDto orderDto = new OrderDto();

        BeanUtils.copyProperties(orderMaster,orderDto);

        return orderDto;
    }

    public static List<OrderDto> convert(List<OrderMaster> orderMasters){
        return orderMasters.stream().map(e -> convert(e))
                .collect(Collectors.toList());
    }
}
